const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost:27017/2404B')
  .then(() => {
    console.log('连接成功');
  })
  .catch((err) => {
    console.log(err, "---连接失败---")
  })

const DishTypeSchema = new mongoose.Schema({
  name:String
})

const DishTypeModel = mongoose.model('dishType', DishTypeSchema, 'dishType')


const DishSchema = new mongoose.Schema({
  type: {
    type:mongoose.Types.ObjectId,
    ref:'dishType'
  },
  name: String,
  price: Number,
  SKU: String,
  flag: Boolean,
  time: Date,
})

const DishModel = mongoose.model('dish', DishSchema, 'dish')

const DishPlanSchema = new mongoose.Schema({
  name: String,
  dishArr: Array,
  price: Number,
  dishLen:Number
})

const DishPlanModel = mongoose.model('dishPlan', DishPlanSchema, 'dishPlan')


module.exports = {
  DishModel, DishPlanModel,DishTypeModel
}